﻿using System.Windows.Forms;

namespace PMC.Interfaces
{
    public partial class ProgressForm : Form, INotifyProgress
    {
        public ProgressForm()
        {
            InitializeComponent();
            StartPosition = FormStartPosition.CenterParent;
        }

        #region Implementation of INotifyProgress

        public void NotifyProgress(int percentage)
        {
            if (IsDisposed)
                return;

            if (percentage > 100)
                percentage = 100;

            if (InvokeRequired)
            {
                Invoke(new MethodInvoker(()=> NotifyProgress(percentage)));
                return;
            }
            Show();
            CenterToScreen();
            pbTotal.Value = percentage;
            
            if (percentage == 100)
                Close();
        }

        #endregion
    }
}
